package app.fugema.shop.main.setting.view;

import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.Switch;

import androidx.core.graphics.drawable.DrawableCompat;

import com.base.common.view.base.BaseTitleActivity;
import com.base.common.viewmodel.BaseViewModel;
import app.fugema.shop.R;
import app.fugema.shop.databinding.SettingNotifyActivityBinding;

public class SettingNotifyActivity extends BaseTitleActivity<SettingNotifyActivityBinding, BaseViewModel> {

    public static void start(Context context) {
        Intent starter = new Intent(context, SettingNotifyActivity.class);
        context.startActivity(starter);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.setting_notify_activity);
    }

    private boolean isPushBack = false;
    private boolean isShowVoice = false;

    @Override
    protected void initView() {
        setTitle("设置");



        binding.scPush.setChecked(false);

        binding.scPush.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isPushBack) {
                    isPushBack = false;
                    return;
                }
            }
        });


        binding.scVoice.setChecked(false);
        binding.scVoice.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isShowVoice) {
                    isShowVoice = false;
                    return;
                }
            }
        });

//        setSwitchColor(binding.scPush);
//        setSwitchColor(binding.scVoice);
    }

    public void setSwitchColor(Switch v) {

        // set the thumb color
        DrawableCompat.setTintList(v.getThumbDrawable(), new ColorStateList(
                new int[][]{
                        new int[]{android.R.attr.state_checked},
                        new int[]{}
                },
                new int[]{
                        0xffFFFFFF,
                        0xffFFFFFF
                }));

        // set the track color
        DrawableCompat.setTintList(v.getTrackDrawable(), new ColorStateList(
                new int[][]{
                        new int[]{android.R.attr.state_checked},
                        new int[]{}
                },
                new int[]{
                        0xff027CF7,
                        0xffE5E7E6
                }));
    }


}
